﻿using System.Linq;
using System.Linq.Expressions;
using Gumini.JulaDB.Provider;
using Remotion.Linq;
using Remotion.Linq.Parsing.Structure;

namespace Gumini.JulaDB.Linq
{
    /// <summary>
    /// Provides the main entry point to a LINQ query.
    /// </summary>
    public class JulaQueryable<T> : QueryableBase<T>
    {
        private static IQueryExecutor CreateExecutor(JulaDbConnection connection)
        {
            return new JulaQueryExecutor(connection);
        }

        /// <summary>
        /// This constructor should be called by users.
        /// </summary>
        public JulaQueryable(JulaDbConnection connection)
            : base(QueryParser.CreateDefault(), CreateExecutor(connection)) { }
        
        /// <summary>
        /// This constructor is called indirectly by LINQ's query methods, just pass to base.
        /// </summary>
        public JulaQueryable(IQueryProvider provider, Expression expression)
            : base (provider, expression) { }
    }
}